<# # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script is designed To retrieve the duplicate files data using specific file path. # Configuration Type - COMPUTER / USER # Note: Based on the folder path type, define it as either computer-based or user-based configurations. #> # Specify the directory you want to search for duplicate filenames (Hardcode the values here) $directoryPath = "C:\Program Files (x86)\ManageEngine\UEMS_Agent\logs" # Get all files in the directory (including subdirectories) $files = Get-ChildItem -Path $directoryPath -Recurse -File # Group files by their names (ignoring the extension) $groupedFiles = $files | Group-Object { $_.BaseName } # Filter groups where there is more than one file (i.e., duplicates) $duplicateFiles = $groupedFiles | Where-Object { $_.Count -gt 1 } # Display the duplicate filenames with their full paths $duplicateFiles | ForEach-Object { Write-Host "Duplicate filename: $($_.Name)" $_.Group | ForEach-Object { Write-Host "`t$($_.FullName)" } }